<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>代办事项列表</title>
    <style>
        div {
            margin: 10px;
        }

        span {
            margin-left: 10px;
        }

        input {
            width: 100px;
            margin-right: 10px;
        }

        li {
            line-height: 2em;
        }
    </style>
</head>

<body>
    <h1>待办事项列表</h1>
    <div>
        <ul id="ul-id">
            <li><button onclick="finished(this)">完成</button><span>第一件事项</span></li>
        </ul>
    </div>

    <div>
        <input type="text" id="input-id" />
        <button id="btn-add">添加一项</button>
    </div>
    <script>
        document.getElementById("btn-add").onclick = function () {
            let val = document.getElementById('input-id').value;
            if (val) {
                let ulNode = document.getElementById('ul-id');
                let doc = `
                    <li><button onclick="finished(this)">完成</button><span>${val}</span></li>
                `;
                ulNode.innerHTML += doc;
            }
        }

        function finished(node) {
            let liNode = node.parentNode;
            let spanNode = liNode.getElementsByTagName('span')[0];
            spanNode.style = "color:green; text-decoration: line-through;";
        }
    </script>
</body>

</html>